﻿namespace VinoCellar.Controls
{
    using System;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Media.Imaging;

    using VinoCellar.Model;

    public partial class WineDetailsControl : UserControl
    {
        public WineDetailsControl()
        {
            InitializeComponent();
        }

        public void Load(WineItem wineItem)
        {
            this.DataContext = wineItem;

            lblName.SetBinding(TextBlock.TextProperty, new Binding("WineName") { Source = wineItem });
            lblAppellation.SetBinding(TextBlock.TextProperty, new Binding("WineAppellation") { Source = wineItem });
            lblCategory.SetBinding(TextBlock.TextProperty, new Binding("WineCategory") { Source = wineItem });
            lblPrice.Text = string.Format("{0:0.00} $", wineItem.WinePrice);
            lblRegion.Text = string.Format("{0}, {1}", wineItem.WineRegion, wineItem.WineSubregion);
            image.Source = new BitmapImage(new Uri(wineItem.WinePictureUrl));

        }
    }
}
